package com.zy.ioc.pro6_ioc_conditional;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @program: mavenTest153
 * @description:
 * @author: zy
 * @create: 2025-07-13 09:40
 */
public class SystemConditional implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        //context就是上下文环境，metadata就是注解的信息
        String userHome= context.getEnvironment().getProperty("user.home");  //用户的家目录
        System.out.println(userHome);
        String userdir= context.getEnvironment().getProperty("user.dir");
        System.out.println(userdir);
        //获取当前系统的名称
        String osName = context.getEnvironment().getProperty("os.name");
        if(  "Linux".equals(osName)){
            return false;
        }
        return true;
    }
}
